﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleRoom.Server
{
    public enum BattleLinkMode
    {
        Direct = -1063922077,
        Agent = -1597211022,
        WrongInput = -1
    }

    public static class BattleLinkModeHelper
    {
        public static BattleLinkMode ReadFromByteArray(ByteArray byteArray)
        {
            int val = byteArray.ReadInt();
            return Parse(val);
        }

        public static BattleLinkMode Parse(int val)
        {
            foreach (int value in Enum.GetValues(typeof(BattleLinkMode)))
            {
                if (value == val) return (BattleLinkMode)value;
            }
            return BattleLinkMode.WrongInput;
        }

        public static void WriteToByteArray(ByteArray byteArray, BattleLinkMode value)
        {
            byteArray.WriteInt((int)value);
        }
    }
}
